package common.exception;


import common.web.StatusCode;
import lombok.Getter;

/**
 * 自定义业务异常
 */
public class ServiceException extends RuntimeException {

    /**
     * 状态码
     */
    @Getter
    private Integer code;

    /**
     *  一个异常消息应该包含什么信息?
     *  message 消息
     *  code 状态码
     */

    public ServiceException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public ServiceException(StatusCode codeEnum, String message) {
        super(message);
        this.code = codeEnum.getCode();
    }

    public ServiceException(StatusCode codeEnum) {
        super(codeEnum.getMsg());
        this.code = codeEnum.getCode();
    }



}
